<?php

namespace IDock\Visitor\Premium;

use IDock\Printer\NonCar\NonCarInquiryPrinter;
use IDock\Visitor\NonCar\NonCarInquiryVisitor;

/**
 * 主询价信息
 */
class PremiumInquiryVisitor
{
    /**
     * 商业险起保日期
     * @var string $biStartData
     */
    public $biStartData = '';

    /**
     * 交强险起保日期
     * @var string $ciStartData
     */
    public $ciStartData = '';

    /**
     * 商业险终保日期
     * @var string $biEndData
     */
    public $biEndData = '';

    /**
     * 交强险终保日期
     * @var string $ciEndData
     */
    public $ciEndData = '';

    /**
     * 商业险即时生效
     * @var string $biEffectFlag
     */
    public $biEffectFlag = '';

    /**
     * 交强险即时生效
     * @var string $ciEffectFlag
     */
    public $ciEffectFlag = '';

    /**
     * 是否新能源
     * @var bool $isNewEnergy
     */
    public $isNewEnergy = false;

    /**
     * 车辆信息
     * @var PremiumVehicleVisitor $vehicleVisitor
     */
    private $vehicleVisitor;

    /**
     * 投保人
     * @var  PremiumRelationVisitor $applicantVisitor
     */
    private $applicantVisitor;

    /**
     * 被保人
     * @var PremiumRelationVisitor $insuredVisitor
     */
    private $insuredVisitor;

    /**
     * 车主
     * @var PremiumRelationVisitor $ownerVisitor
     */
    private $ownerVisitor;

    /**
     * 车船税
     * @var PremiumCarTaxVisitor $carTaxVisitor
     */
    private $carTaxVisitor;

    /**
     * 险种列表
     * @var array $coverageVisitor
     */
    private $coverageVisitorList = [];

    /**
     * 充电桩信息
     * @var array $chargingPileVisitor
     */
    private $chargingPileVisitorList = [];

    /**
     * 上次文件
     * @var array $fileList
     */
    private $fileList = [];

    /**
     * 拓展信息
     * @var PremiumExtInfoVisitor $extInfoVisitor
     */
    private $extInfoVisitor;

    /**
     * 核保参数
     * @var PremiumUnderwritingVisitor $underwritingVisitor
     */
    private $underwritingVisitor;

    /**
     * 续保信息
     * @var PremiumRenewalVisitor  $PremiumRenewalVisitor
     */
    private $premiumRenewalVisitor;

    /**
     * 非车询价信息
     * @var  NonCarInquiryVisitor $nonCarInquiryVisitor
     */
    private $nonCarInquiryVisitor;

    /**
     * 非车核保信息
     * @var NonCarInquiryVisitor $nonCarUnderwritingVisitor
     */
    private $nonCarUnderwritingVisitor;


    /**
     * 车辆信息
     * @param mixed $vehicleVisitor
     */
    public function setVehicleVisitor(PremiumVehicleVisitor $vehicleVisitor): void
    {
        $this->vehicleVisitor = $vehicleVisitor;
    }

    /**
     * 投保人信息
     * @param PremiumRelationVisitor $applicantVisitor
     */
    public function setApplicantVisitor(PremiumRelationVisitor $applicantVisitor): void
    {
        $this->applicantVisitor = $applicantVisitor;
    }

    /**
     * 被保人信息
     * @param PremiumRelationVisitor $insuredVisitor
     */
    public function setInsuredVisitor(PremiumRelationVisitor $insuredVisitor): void
    {
        $this->insuredVisitor = $insuredVisitor;
    }

    /**
     * 车主信息
     * @param PremiumRelationVisitor $ownerVisitor
     */
    public function setOwnerVisitor(PremiumRelationVisitor $ownerVisitor): void
    {
        $this->ownerVisitor = $ownerVisitor;
    }

    /**
     * 车船税信息
     * @param PremiumCarTaxVisitor $carTaxVisitor
     * @return void
     */
    public function setCarTaxVisitor(PremiumCarTaxVisitor $carTaxVisitor) :void
    {
        $this->carTaxVisitor = $carTaxVisitor;
    }

    /**
     * 险种添加
     * @param PremiumCoverageVisitor $coverageVisitor
     * @return void
     */
    public function coverageVisitorAppend(PremiumCoverageVisitor $coverageVisitor): void
    {
        $this->coverageVisitorList[] = $coverageVisitor;
    }

    /**
     * 充电桩信息
     * @param PremiumChargingPileVisitor $chargingPileVisitor
     * @return void
     */
    public function chargingPileVisitorAppend(PremiumChargingPileVisitor $chargingPileVisitor): void
    {
        $this->chargingPileVisitorList[] = $chargingPileVisitor;
    }

    /**
     * 拓展信息
     * @param PremiumExtInfoVisitor $extInfoVisitor
     * @return void
     */
    public function setExtInfoVisitor(PremiumExtInfoVisitor $extInfoVisitor): void
    {
        $this->extInfoVisitor = $extInfoVisitor;
    }

    /**
     * 核保信息
     * @param PremiumUnderwritingVisitor $underwritingVisitor
     */
    public function setUnderwritingVisitor(PremiumUnderwritingVisitor $underwritingVisitor): void
    {
        $this->underwritingVisitor = $underwritingVisitor;
    }

    /**
     * 非车询价信息
     * @param NonCarInquiryVisitor $nonCarInquiryVisitor
     */
    public function setNonCarInquiryVisitor(NonCarInquiryVisitor $nonCarInquiryVisitor): void
    {
        $this->nonCarInquiryVisitor = $nonCarInquiryVisitor;
    }

    /**
     * 非车核保
     * @param NonCarInquiryVisitor $nonCarUnderwritingVisitor
     */
    public function setNonCarUnderwritingVisitor(NonCarInquiryVisitor $nonCarUnderwritingVisitor): void
    {
        $this->nonCarUnderwritingVisitor = $nonCarUnderwritingVisitor;
    }

    /**
     * 续保信息
     * @param PremiumRenewalVisitor $premiumRenewalVisitor
     */
    public function setPremiumRenewalVisitor(PremiumRenewalVisitor $premiumRenewalVisitor): void
    {
        $this->premiumRenewalVisitor = $premiumRenewalVisitor;
    }

    /**
     * 图片上传
     * @param string $type
     * @param string $fileUrl
     * @param string $base64
     * @return void
     * @version 4.0
     */
    public function fileAppend(string $type, string $fileUrl = '', string $base64 = '') {
        $this->fileList[] = [
            'type' => $type,
            'url' => $fileUrl,
            'base64' => $base64
        ];
    }

    /**
     * @return string
     */
    public function getBiStartData(): string
    {
        return $this->biStartData;
    }

    /**
     * @return string
     */
    public function getCiStartData(): string
    {
        return $this->ciStartData;
    }

    /**
     * @return string
     */
    public function getBiEndData(): string
    {
        return $this->biEndData;
    }

    /**
     * @return string
     */
    public function getCiEndData(): string
    {
        return $this->ciEndData;
    }

    /**
     * @return string
     */
    public function getBiEffectFlag(): string
    {
        return $this->biEffectFlag;
    }

    /**
     * @return string
     */
    public function getCiEffectFlag(): string
    {
        return $this->ciEffectFlag;
    }

    /**
     * @return PremiumVehicleVisitor
     */
    public function getVehicleVisitor(): PremiumVehicleVisitor
    {
        return $this->vehicleVisitor;
    }

    /**
     * @return PremiumRelationVisitor
     */
    public function getApplicantVisitor(): PremiumRelationVisitor
    {
        return $this->applicantVisitor;
    }

    /**
     * @return PremiumRelationVisitor
     */
    public function getInsuredVisitor(): PremiumRelationVisitor
    {
        return $this->insuredVisitor;
    }

    /**
     * @return PremiumRelationVisitor
     */
    public function getOwnerVisitor(): PremiumRelationVisitor
    {
        return $this->ownerVisitor;
    }

    /**
     * @return PremiumCarTaxVisitor
     */
    public function getCarTaxVisitor(): PremiumCarTaxVisitor
    {
        return $this->carTaxVisitor;
    }

    /**
     * @return array
     */
    public function getFileList(): array
    {
        return $this->fileList;
    }

    /**
     * @return array
     */
    public function getCoverageVisitorList(): array
    {
        return $this->coverageVisitorList;
    }

    /**
     * @return array
     */
    public function getChargingPileVisitorList(): array
    {
        return $this->chargingPileVisitorList;
    }

    /**
     * @return PremiumExtInfoVisitor
     */
    public function getExtInfoVisitor(): PremiumExtInfoVisitor
    {
        return $this->extInfoVisitor;
    }

    /**
     * @return PremiumUnderwritingVisitor
     */
    public function getUnderwritingVisitor(): PremiumUnderwritingVisitor
    {
        return $this->underwritingVisitor;
    }

    /**
     * @return NonCarInquiryVisitor
     */
    public function getNonCarInquiryVisitor(): NonCarInquiryVisitor
    {
        return $this->nonCarInquiryVisitor;
    }

    /**
     * @return NonCarInquiryVisitor
     */
    public function getNonCarUnderwritingVisitor(): NonCarInquiryVisitor
    {
        return $this->nonCarUnderwritingVisitor;
    }

    /**
     * @return PremiumRenewalVisitor
     */
    public function getPremiumRenewalVisitor(): PremiumRenewalVisitor
    {
        return $this->premiumRenewalVisitor;
    }

    /**
     * 获取拓展信息
     * @param $key
     * @param $default
     * @return mixed|string
     */
    public function getExtInfo($key, $default = null)
    {
        if (property_exists($this->extInfoVisitor, $key)) {
            return $this->extInfoVisitor->$key;
        }

        $extInfoArgc = $this->extInfoVisitor->argc;

        return $extInfoArgc[$key] ?? $default;
    }


}
